﻿package mortal.game.view.common.tooltip.tooltips
{
    import Message.DB.Tables.*;
    import __AS3__.vec.*;
    import baseEngine.modifiers.*;
    import flash.geom.*;
    import frEngine.*;
    import frEngine.event.*;
    import frEngine.pools.*;
    import mortal.game.model.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.scene3D.model.player.*;
    import mortal.game.scene3D.model.pools.*;
    import mortal.game.utils.*;

    public class ToolTipPetEgg extends ToolTipBaseItem3D
    {
        private var _petInfo:TPetConfig;

        public function ToolTipPetEgg()
        {
            return;
        }// end function

        override public function set data(param1) : void
        {
            super.data = param1;
            var _loc_2:* = _data.itemInfo.effect;
            this._petInfo = PetConfig.instance.getInfoByCode(_loc_2);
            if (this._petInfo != null)
            {
                add3DModel();
            }
            return;
        }// end function

        override protected function set3dModel() : void
        {
            var _loc_5:int = 0;
            var _loc_6:Vector.<Array> = null;
            var _loc_7:Array = null;
            var _loc_8:Array = null;
            var _loc_9:EffectPlayer = null;
            var _loc_1:* = PetUtil.getPetModel(1, this._petInfo.model);
            var _loc_2:* = _loc_1.mesh + ".md5mesh";
            var _loc_3:* = _loc_1.bone + ".skeleton";
            if (_3dObj)
            {
                _rect3D.disposeObj3d(_3dObj);
            }
            _3dObj = FrObjectPool.getObject(ActionPlayer, this);
            var _loc_4:* = _3dObj as ActionPlayer;
            FrEventDispatcher.instance.proxyAddEventListener(_loc_4, Engine3dEventName.PARSE_MESH_FINISH, this.modleLoadedHandler);
            _loc_4.selectEnabled = true;
            _loc_4.setRotation(0, 0, 0);
            var _loc_10:int = 1;
            _loc_4.scaleZ = 1;
            var _loc_10:* = _loc_10;
            _loc_4.scaleY = _loc_10;
            _loc_4.scaleX = _loc_10;
            _loc_4.load(_loc_2, _loc_3, _loc_1.texture, _rect3D.renderList);
            if (_loc_1.effect)
            {
                _loc_6 = GameStrUtil.alzToArray(_loc_1.effect);
                _loc_7 = _loc_6[0];
                _loc_8 = _loc_6[1];
                _loc_5 = 0;
                while (_loc_5 < _loc_7.length)
                {
                    
                    _loc_9 = EffectPlayerPool.instance.getEffectPlayer(_loc_7[_loc_5], null, _rect3D.renderList, false);
                    _loc_9.hangBoneName = _loc_8[_loc_5];
                    _loc_4.hang(_loc_9);
                    _loc_9.play(PlayMode.ANIMATION_LOOP_MODE);
                    _loc_5++;
                }
            }
            _loc_4.play();
            return;
        }// end function

        override protected function modleLoadedHandler(param1 = null) : void
        {
            FrEventDispatcher.instance.proxyAddEventListener(_3dObj, Engine3dEventName.PARSE_MESH_FINISH, this.modleLoadedHandler);
            var _loc_2:* = (_3dObj as ActionPlayer).bounds.length;
            var _loc_3:Number = 1;
            if (_loc_2.y > _3dRectHeight - 30)
            {
                _loc_3 = (_3dRectHeight - 30) / _loc_2.y;
            }
            var _loc_5:* = _loc_3;
            _3dObj.scaleZ = _loc_3;
            var _loc_5:* = _loc_5;
            _3dObj.scaleY = _loc_5;
            _3dObj.scaleX = _loc_5;
            var _loc_4:int = 50;
            if (_loc_2.y * _loc_3 * Math.sin(_loc_4 / 180 * Math.PI) > _3dRectWidth * 0.5)
            {
                _loc_4 = Math.asin(_3dRectWidth * 0.5 / _loc_2.y * _loc_3) * 180 / Math.PI;
            }
            (_3dObj as ActionPlayer).rotationY = _loc_4;
            return;
        }// end function

    }
}
